package cn.fangline.wo.task.akka.mailbox;

import akka.actor.ActorSystem;
import akka.dispatch.PriorityGenerator;
import akka.dispatch.UnboundedPriorityMailbox;
import cn.fangline.wo.task.akka.messages.CheckAlive;
import com.typesafe.config.Config;

public class CommonUnboundedPriorityMailbox extends UnboundedPriorityMailbox {

    public CommonUnboundedPriorityMailbox(ActorSystem.Settings settings, Config config) {

        // Creating a new PriorityGenerator,
        super(new PriorityGenerator() {
            @Override
            public int gen(Object message) {
                if (message instanceof CheckAlive) {
                    // treated with highest priority
                    return 0;
                }
                else {
                    return 2;
                }
            }
        });
    }
}